﻿<!doctype html>
<html><!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>会员地域统计</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/sub.js"></script><!-- 标签切换 -->
<script type="text/javascript" src="../js/gbRst.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/highcharts.js"></script>
<script type="text/javascript" src="../js/exporting_1.js"></script>
<script type="text/javascript" src="../js/huituUtils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<link href="../css/style.css" type="text/css" rel="stylesheet" />

<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->


</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
<script type="text/javascript">
$(function(){	
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});
});
$(function(){
	$("#nowYear").change(function(){
		findMemberCount()
	})
})
//选年份的下拉框
</script>

<script type="text/javascript">
		var year = null
			
			$(document).ready(function() {
				var year = new Date()
					/* 	$.ajax({
						type : "get",
						datatype : "json",
						url : "../member/find/memberCount",
						data : {'year':year},
						success : function(data) {
							var rst = JSON.parse(data);
								if(rst.state==0){
									 	$("#allCount").html(rst.result.data[0][0])
									 	$("#yesCount").html(rst.result.data[0][1])
									}
						}	
					});
					
				var now=new Date();
				endTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtEnd").val(endTime)	
				now.setTime(now.getTime()-30*24*3600*1000);
				beginTime=now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
				$("#dtBegin").val(beginTime)	 */
			
				findMemberCount()
			});
			
			
			function findMemberCount(){		
				/* var beginTime=$("#dtBegin").val();
				var endTime = $("#dtEnd").val();
				var param="timeBegin="+beginTime+"&timeEnd="+endTime; */
				$.ajax({
						type : "get",
						async:false,
						datatype : "json",
						data:{'year':year},
						url : "../member/find/memberLocation",
						success : function(data) {
							var rst = JSON.parse(data);
									if(IsEmpty(rst)){
										art.dialog({fixed:true, lock: true,content:"查询错误",icon:'error',ok:true});	
										return false;
										}
										if(rst.state==0){
									makeParam(rst);
									}else if(rst.state==1){
									art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
									}else{
											checkStateShowErrorMsgAndDealResult(data);
									}			
									
									
						}	
					});
				
			}
			
			function makeParam(json){
				var param = [];
				var all = 0;
				var mAll = 0;
				var city = new Array();
				var cityV = new Array()
				$("#memberList1 tbody ").empty();
				for(m=0;m<json.result.data.length;m++){
					var count =getHtmlInt( getHeadIndexValue(m, json, "count")) 
					/* if(IsEmpty(time)){
						time="其它"
					} */
					all+=count;
					
					}
				var qitaCount = 0;
				for(m=0;m<json.result.data.length;m++){
					var count = getHeadIndexValue(m, json, "count")
					var pName = getHeadIndexValue(m, json, "pName")
					var cnName = getHeadIndexValue(m, json, "cnName")
					var ccnName = getHeadIndexValue(m, json, "ccnName")
					var p = getHeadIndexValue(m, json, "p")
					var c = getHeadIndexValue(m, json, "c")
					var cc = getHeadIndexValue(m, json, "cc")
					var cFlag = false;
					for ( var j = 0; j < city.length; j++) {
						if(c == city[j]){
							cFlag = true;
						}
					}
					if(IsEmpty(pName)){
						cnName="其它"
						ccnName = '其它'
						qitaCount = count;
					}
										
					if(cFlag){
						var num = $("#tr_"+c +" td:first").attr("rowspan");
						if(IsEmpty(num)){
							num=1;
						}
						$("#tr_"+c +" td:first").attr("rowspan",num+1)
						var value= jisuan(count, all, 1)
						var htm ="<tr><td>"+ccnName+"</td><td>"+count+"</td><td>"+value+"</td></tr>"
						$("#tr_"+c).after(htm)
						
					}else{
						city.push(c)
						$("#memberList1 tbody ");
						var value= jisuan(count, all, 1)
						if(cnName=="市辖区"||cnName=="县"){
							cnName = pName;
						}
						var htm ="<tr id='tr_"+c+"' ><td>"+cnName+"</td><td>"+ccnName+"</td><td>"+count+"</td><td>"+value+"</td></tr>"

					$("#memberList1 tbody").prepend(htm);
		
					}
										
					
				}
				
				var x = 0;
				for ( var j = 0; j < city.length; j++) {
					var tiCount = 0
					var cN = ""
					var name = "";
					for(m=0;m<json.result.data.length;m++){
						var count =getHtmlInt( getHeadIndexValue(m, json, "count")) 
						var c =getHtmlInt( getHeadIndexValue(m, json, "c"))
						var cname =getHtmlInt( getHeadIndexValue(m, json, "cnName"))
						var pName = getHeadIndexValue(m, json, "pName")
		 			
						if(cname=="市辖区"||cname=="县"){
							cname = pName;
						}
						if(c == city[j]){
							tiCount+=count;
							name = cname
						}
						}
					if(IsNotEmpty(name)){
					var value=[name+"："+tiCount+"人",tiCount]
					param[x]=value;
					x++;
					}

				}
				if(qitaCount>0){
				var ms=["其它："+qitaCount+"人",qitaCount]
				param[--city.length]  = ms;
				}
				
				
				
				
				
				$("#memberList1 tbody ").append("<tr></tr>");
				
				$("#memberList1 tbody tr:last").append("<td colspan='2'>总计</td>").append("<td>"+all+"</td>").append("<td>100.0%</td>");
				 
				huitu("container1", param, "会员地域统计", "所占比例：");

				//highChars(param,"新注册会员统计","注册数：");
			}
			
			function jisuan(num1,num2,xiaoshu){
				var c = num1/num2*100;
				return parseFloat(c).toFixed(xiaoshu)+"%"
			}
			/* function highChars(param,title,name){//绘图
			 var s=	new Highcharts.StockChart({
					chart: {
						renderTo: 'container1',
						marginRight: 30,
						marginBottom: 25
					},
				 credits:{
					 enabled :false
				 },
				 
					exporting:{
						enabled:false,
						show:false
					},
					rangeSelector: {
						show:false,
						enable:true,
				        buttons: [{
				            type: 'day',
				            count: 3,
				            text: '3天'
				        }, {
				            type: 'week',
				            count: 1,
				            text: '1周'
				        }, {
				            type: 'month',
				            count: 1,
				            text: '1个月'
				        }, {
				            type: 'month',
				            count: 6,
				            text: '6个月'
				        }, {
				            type: 'year',
				            count: 1,
				            text: '1年'
				        }, {
				            type: 'all',
				            text: '所有'
				        }],
				        selected: 6
				    },
					title: {
						text: title
						
					},
					subtitle: {
						text: ''
						
					},
					xAxis:{
			            labels: {  
			            formatter: function() {  
			                var vDate=new Date(this.value);  
			                return (vDate.getMonth()+1)+"-"+vDate.getDate();  
			            },
			            maxStaggerLines:3
						},
						minRange:7*24*3600*1000
						},
					yAxis: {
						title: {
							text: ''
						},
						plotLines: [{
							value: 0,
							width: 1,
							color: '#808080'
						}],
						min:0
					},
					 tooltip: {  
				            xDateFormat: '%Y-%m-%d'//鼠标移动到趋势线上时显示的日期格式  
				        },  
					legend: {
						layout: 'vertical',
						align: 'right',
						verticalAlign: 'top',
						x: -10,
						y: 100,
						borderWidth: 0
					},
					series: [{
						name: name,
						data: param,
						 pointInterval: 24*3600 * 1000,
					        tooltip: {
					        	valueSuffix: '人'
					        }
					}]
				});
			 	
			} */
				
	$(function(){
		$("#sub_s1").click(function(){
			findMemberCount(1)
			$("#search_btn2").hide()
			$("#search_btn1").show();
			$(this).addClass("focus");
			$("#sub_s2").removeClass("focus");
		})
		$("#sub_s2").click(function(){
			findMemberCount(2)
			$("#search_btn1").hide()
			$("#search_btn2").show();
			$(this).addClass("focus");
			$("#sub_s1").removeClass("focus");
		})
	})		
		</script><!-- 折线图 -->
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place">会员地域统计</div>
    <!-- <div class="shadow yesterday_all">
    	<h2 class="title">会员统计</h2>
        <ul class="main_number">
        	<li class="noBorder"><strong >新会员</strong><span id="yesCount"></span></li>
        	<li><strong>总会员</strong><span id="allCount"></span></li>
        </ul>
        <div class="fc"></div>
    </div> -->
<!--     <div class="member_search"><select id="nowYear"></select></div>
 -->    <div class="shadow yesterday_all" id="bigBox">
<!--     	<h2 class="title">关键指标详解<div id="sub"><span class="focus" id="sub_s1">新增会员</span><span id="sub_s2">累积会员</span></div></h2>
 --><!--     	<div class="search_term"><span>起始日期：</span><input type="text" readonly class="doubledate ipticon"  id="dtBegin"/><span>截止时间：</span><input type="text" readonly class="doubledate ipticon" id="dtEnd"/><input type="button" id="search_btn1" class="search_btn common_btn" onclick="findMemberCount(1)" value="查询"><input type="button" id="search_btn2" style="display: none;" class="search_btn common_btn" onclick="findMemberCount(2)" value="查询"></div>
 -->        	<div class="box_img">
            	<h4>统计图</h4>
                <div class="line_img"><div id="container1" style="width: 100%; height: 400px; margin: 0 auto"></div></div>
            </div>
            
          <div>
           <table  width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList1">
    	<thead>
    	<tr >
        	<th >城市</th>
        	<th>地区</th>
        	<th>累计数量</th>
        	<th>占比 </th>
        </tr>
        </thead>
    	<tbody></tbody>
    </table>
          </div>   
        	   
    </div>
  </div>
  <div class="fc"></div>
</div>
<script type="text/javascript">

</script>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
<script type="text/javascript">
showTab(9,2);
</script>
</body>
<!-- InstanceEnd --></html>
